import { debounce } from "./utils";
import BackTop from "components/content/backTop/BackTop";

export const itemImageListener = {
  data() {
    return {
      itemImageListener: null
    };
  },
  mounted() {
    this.itemImageListener = () => {
      refresh();
    };
    const refresh = debounce(this.$refs.scroll.refresh, 50);
    this.$bus.$on("itemImgLoad", this.itemImageListener);
  }
};
// 抽取backTop
export const isShowBackTop = {
  components: {
    BackTop
  },
  data() {
    return {
      backIsShow: false
    };
  },
  methods: {
    ShowBackTop(position) {
      this.backIsShow = -position.y > 1000;
    },
    backClick() {
      this.$refs.scroll.scrollTo(0, 0);
    }
  }
};

export const tabControlMixin = {
  data() {
    return {
      currentType: "pop"
    };
  },
  methods: {
    tabClick(index) {
      switch (index) {
        case 0:
          this.currentType = "pop";
          break;
        case 1:
          this.currentType = "new";
          break;
        case 2:
          this.currentType = "sell";
          break;
      }
      console.log(this.currentType);
    }
  }
};
